package com.kylinhunter.ui.tools;

import java.awt.Component;

import javax.swing.ImageIcon;
import javax.swing.JTree;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.DefaultTreeCellRenderer;

import com.kylinhunter.ch.plugin.knowledgebase.dao.Chcode;
import com.kylinhunter.ch.plugin.knowledgebase.dao.Chkbfile;

public   class  CategoryNodeRenderer  extends  DefaultTreeCellRenderer{
	private   static   final   long  serialVersionUID  =   8532405600839140757L ;

	private   static   final  ImageIcon categoryLeafIcon  =   new  ImageIcon(CategoryNodeRenderer. class .getResource("categoryLeaf.png " ));
	private   static   final  ImageIcon openFolderIcon  =   new  ImageIcon(CategoryNodeRenderer. class .getResource("openFolder.png" ));
	private   static   final  ImageIcon closedFolderIcon  =   new  ImageIcon(CategoryNodeRenderer. class .getResource("closedFolder.png" ));

	public  Component getTreeCellRendererComponent(JTree tree,
			Object value,
			boolean  sel,
			boolean  expanded,
			boolean  leaf,
			int  row,
			boolean  hasFocus){

		super .getTreeCellRendererComponent(tree,  
				value,
				sel,  
				expanded,  
				leaf,  
				row,  
				hasFocus); 
		
		DefaultMutableTreeNode node=(DefaultMutableTreeNode) value;
		TreeValue tv=(TreeValue) node.getUserObject();
		Object treeobj=tv.getTreeobj();
		if(treeobj instanceof Chcode){
			setIcon(openFolderIcon);
		}
		if(treeobj instanceof Chkbfile){
			setIcon(closedFolderIcon);
		}

		 

		return   this ;   
	}
} 
